package com.hopes.bizz.poll.alarm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopes.bizz.poll.alarm.bo.AlarmStatistics;
import com.hopes.bizz.poll.alarm.dto.AlarmStatisticsRequest;
import com.hopes.bizz.poll.alarm.service.PollAlarmStatisticsService;
import com.hopes.boss.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/5/30 15:32
 * @Description:
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/alarmStatistics" )
@Tag(description = "alarmStatistics" , name = "报警信息统计" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class PollAlarmStatisticsController {

    private final PollAlarmStatisticsService pollAlarmStatisticsService;
    /**
     * 报警数据统计
     * @return R
     */
    @Operation(summary = "报警数据统计" , description = "报警数据统计" )
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('alarm_statistics_view')" )
    public R getStatistics(Page page, AlarmStatisticsRequest request) {
        List<AlarmStatistics> statistics = pollAlarmStatisticsService.getStatistics(page, request);
        page.setRecords(statistics);
        return R.ok(page);
    }
}
